package ngames.com.sushitv.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.ArrayList;

import ngames.com.sushitv.R;
import ngames.com.sushitv.base.BaseListAdapter;
import ngames.com.sushitv.entity.ItemVideo;

/**
 * Created by Jeffrey on 2016/7/27.
 */
public class DemoAdapter extends BaseListAdapter<ItemVideo> {

    public DemoAdapter(Context context, ArrayList<ItemVideo> list) {
        super(context, list);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new DemoViewHolder(mInflater.inflate(R.layout.item_demo_list, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        DemoViewHolder demoViewHolder = (DemoViewHolder) holder;
        demoViewHolder.setData(position);
    }

    class DemoViewHolder extends RecyclerView.ViewHolder {
        TextView nameTv;

        public DemoViewHolder(View itemView) {
            super(itemView);
            nameTv = (TextView) itemView.findViewById(R.id.txv_name);
        }

        public void setData(int position) {
            ItemVideo itemVideo = getItem(position);
            nameTv.setText(itemVideo.getTitle());
        }
    }
}
